﻿using System;
using System.Data.SqlClient;

namespace HashFoo.SqlServer.TransientDbConnection
{
    public interface ISqlExceptionProvider
    {
        /// <summary>
        /// Gets a sql exception from the type of a specific exception.
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        SqlException GetFrom<TEx>(TEx ex) where TEx : Exception;

        /// <summary>
        /// True if the provider can get a <see cref="SqlException"/> from the <typeparamref name="TEx"/> exception.
        /// </summary>
        /// <typeparam name="TEx"></typeparam>
        /// <param name="ex"></param>
        /// <returns></returns>
        bool Handles<TEx>(TEx ex) where TEx : Exception;
    }
}